#include "myplane.h"
#include<QDebug>
myplane::myplane()
{
    plane.load(":/sucai/10013.png");
    //初始化飞机坐标
    mx=250-plane.width()*0.5;
    my=800-plane.height();
    //初始化矩形边框
    mrect.setWidth(plane.width());
    mrect.setHeight(plane.height());
    mrect.moveTo(mx,my);
}
void myplane::shoot()
{
    //累加时间间隔
    mrecorder++;
    //如果记录的数字未达到发射时间间隔，直接return
    if(mrecorder<20)
    {
        return;
    }
    //达到发射时间
    mrecorder=0;
    //发射子弹
    for(int i=0;i<30;i++)
    {
        //如果是空闲子弹，发射
        if(mbullets[i].mfree==true)
        {
            mbullets[i].mfree=false;
            mbullets[i].mx=mx+mrect.width()*0.5-15;
            mbullets[i].my=my-25;
            break;
        }
    }
}
void myplane::setPosition(int x,int y)
{
    mx=x;
    my=y;
    mrect.moveTo(mx,my);
}
